package com.kltn.zigo.data.insert;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.kltn.zigo.data.IP;
import com.kltn.zigo.process.JSONParser;

public class DetailGroupCustomerPlaceInsert {
	JSONParser jsonParser = new JSONParser();
    
    // url to get all DetailUtilityPlace list
    private static String url_insert_detail_group_customer_place = IP.get_IP() + IP.get_path_service() + "insert_detail_group_customer_place.php";
    private static final String TAG_SUCCESS = "success";

    String place_id;
    String group_customer_id;
    
    public DetailGroupCustomerPlaceInsert(String PlaceId, String GroupCustomerId)
    {
    	place_id = PlaceId;
    	group_customer_id = GroupCustomerId;
    }
    
    public void InsertDetailGroupCustomerPlace()
	{
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("place_id", place_id));
        params.add(new BasicNameValuePair("group_customer_id", group_customer_id));

        // getting JSON Object
        // Note that create place url accepts POST method
        JSONObject json = jsonParser.makeHttpRequest(url_insert_detail_group_customer_place, "POST", params);

        // check log cat fro response
        Log.d("Create Response", json.toString());

        // check for success tag
        try {
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // successfully created placex
                //Intent i = new Intent(activity.getApplicationContext(), ListPlaceActivity.class);
                //activity.startActivity(i);

                // closing this screen
                //activity.finish();
                
            } else {
                // failed to create place
            	
            	
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
	}
}